<?php

#doc
#	classname:	QBannersController
#	scope:		PUBLIC
#
#/doc

class QBannersController extends Controller
{
	public $layout="admin";
	
	public function filters()
		{
			return array(
				'accessControl',
			);
		}

		public function accessRules()
		{
		return array(


		array('allow',
			'actions'=>array('add','Edit','Delete'),
			'roles'=>array('admin')

			),
			array('deny',
			'actions'=>array('add','Edit','Delete'),
			'users'=>array('*')

			),


		);
	 }
	
	public function actionAdd ()
	{
		if (isset($_POST['baner']))
		{	
			$baners=new baners();
			$img = CUploadedFile::getInstance($baners,'img');
			$upload = Yii::getPathOfAlias('open29').Yii::app()->controller->module->uploadPath;
			if($img != null)
			{      
				$img->saveAs("images/baners/".$img);   
			}
			$baners->image=$img;
			
			if ($baners->save())
			{
				$this->redirect(array('addbanners'));
			}
		}
		$this->render('application.views.qbanners.addbanners');
	}
	
	public function actionEdit ()
	{
		$banners=baners::model()->findAll();
		$this->render('application.views.qbanners.editbanners',array("banners"=>$banners));
	}
	
	public function actionDel ()
	{
		$id_baner=$_GET['id'];
		baners::model()->deleteAll("id_baner=:id_baner",array(":id_baner"=>$id_baner));
		$this->redirect('/adminka/qbanners/edit');
	}

}
###

?>